{php include wl_template('common/header');}
{if $_GPC['type']=='settlement'}
<div class="main">
	<ul class="nav nav-tabs">
		<li {if $_GPC['type']=='settlement' && $_GPC['accountType']=='f2f' }class="active"{/if}><a href="{php echo web_url('finace/wlCash/settlement', array('id'=>$id,'accountType'=>'f2f'));}">手动结算</a></li>
		<!--<li {if $_GPC['type']=='settlement' && $_GPC['accountType']=='weixin'}class="active"{/if}><a href="{php echo web_url('finace/wlCash/settlement', array('id'=>$id,'accountType'=>'weixin'));}">结算到微信钱包</a></li>-->
	</ul>
{if $_GPC['type']=='settlement' && $_GPC['accountType']=='weixin'}
	<div id="weixin">
	    <div class="panel panel-default">
	    <div class="panel-heading">结算注意</div>
	    <div class="panel-body">
            <div class="form-group">
            	<label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                1.<font color="red" size="3">总交易</font>金额：用户支付过的金额总和。<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<1>以下情况会<font color="red" size="3">增加</font>总交易金额：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.用户支付购买商品金额；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<2>以下情况会<font color="red" size="3">减少</font>总交易金额：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.退款后；<br>
                
                </label>
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                2.<font color="red" size="3">可结算</font>金额：可以结算给商户的实际金额。<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<1>以下情况会将订单实际支付金额<font color="red" size="3">增加</font>到可结算金额：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.核销后：后台订单列表核销，后台订单详情核销，微信端扫码核销，微信端验证码核销；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;②.发货后：后台订单详情里发货，后台批量发货；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<2>以下情况会<font color="red" size="3">减少</font>可结算金额：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.取消核销后：后台订单详情取消核销；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;②.取消发货后：后台订单详情里取消发货；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;③.用户结算后；
                
                </label>
                {if !MERCHANTID}
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                3.结算金额必须大于1元。
                </label>
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                4.请确认微信商户后台有足够的<font color="red" size="3">可用余额</font>。
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                5.结算金额直接提现到该商家<font color="red" size="3">提现微信号</font>的<font color="red" size="3">微信钱包</font>中，<font color="red" size="3">注意绑定正确的微信号</font>，必要时可结算1元到该微信号上<font color="red" size="3">验证</font>是否绑定正确。
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                6.佣金举例：佣金百分比为10%，需要给商家结算100元，则商家实际到账90元，佣金为10元。
                </label>
			         <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">       接口调用规则：<br>
				
				◆ 给同一个实名用户付款，单笔单日限额2W/2W<br>
				
				◆ 给同一个非实名用户付款，单笔单日限额2000/2000<br>
				
				◆ 一个商户同一日付款总额限额100W<br>
				
				◆ 单笔最小金额默认为1元<br>
				
				◆ 每个用户每天最多可付款10次，可以在商户平台--API安全进行设置<br>
				
				◆ 给同一个用户付款时间间隔不得低于15秒
 			</label>
				{/if}
	   		</div>
	    </div>
	</div> 
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
<div class="panel panel-default">
    <div class="panel-heading">
        结算
    </div>
    <div class="panel-body">
         <div class="form-group">
            <label class="col-sm-2 control-label">申请总金额</label>
            <div class="col-sm-9">
                <div class="form-control-static">{if $settlementRecord['sapplymoney']}{$settlementRecord['sapplymoney']}元{else}0.00元{/if}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">佣金百分比</label>
            <div class="col-sm-9">
                <div class="form-control-static">{if $merchant['percent']}{$merchant['percent']}%{else}0.00%{/if}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">代理收入</label>
            <div class="col-sm-9">
                <div class="form-control-static">{if $settlementRecord['agetmoney']}{$settlementRecord['agetmoney']}元{else}0.00元{/if}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">商户收入</label>
            <div class="col-sm-8 col-lg-3 col-xs-12">
                <input class="form-control" name="money" id="" type="text" value="{php echo sprintf("%.2f",$settlementRecord['aapplymoney'] -  $merchant['percent']*$settlementRecord['aapplymoney']/100)}" placeholder="">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"></label>
            <div class="col-sm-9">
                    <input type="hidden" name="id" value="{$id}">
                    <input type="hidden" name="accountType" value="{$_GPC['accountType']}">
                    <input type="hidden" name="token" value="{$_W['token']}">
                    <input name="submit" type="submit" value="结 算" class="btn btn-primary span2" onclick="return confirm('确认？');return false;">
            </div>
           </div>
  
        </div>
    </div>
</form>
</div>
{/if}
{if $_GPC['type']=='settlement' && $_GPC['accountType']=='f2f'}

<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
<div class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-hover" style="min-width: 300px;">
			<thead class="navbar-inner">
				<tr>
					<th class="col-sm-2">申请信息</th>
					<th class="col-sm-2">申请金额</th>
					<th class="col-sm-2">总提成</th>
					<th class="col-sm-2">代理提成<br>系统提成</th>
					<th class="col-sm-9">提现</th>
					<th class="col-sm-2">申请时间</th>
					<th class="col-sm-2">操作时间</th>
					<th class="col-sm-3">状态</th>
					<th class="col-sm-1">单数</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>{if $settlementRecord['type']==1}商家：{$settlementRecord['sName']}{else}代理：{$settlementRecord['aName']}{/if}</td>
					<td>{if $settlementRecord['type']==1}{$settlementRecord['sapplymoney']}{else}{$settlementRecord['aapplymoney']}{/if}元</td>
					<td>{if $settlementRecord['type']==1}{$settlementRecord['spercent']}{else}{$settlementRecord['apercent']}{/if}%</td>
					<td>{if $settlementRecord['type']==1}{$settlementRecord['apercent']}%<br>{php echo sprintf("%.4f", $settlementRecord['spercent'] - $settlementRecord['apercent'])}%{else}0.0000%<br>{$settlementRecord['apercent']}%{/if}</td>
					<td>{if $settlementRecord['type']==1}<label class="label label-default label-danger">商家销售提现</label>【{if $settlementRecord['type2']==1}超级券{else}抢购{/if}】{/if}
						{if $settlementRecord['type']==2}<label class="label label-default label-danger">VIP申请提现</label>{/if}
						{if $settlementRecord['type']==3}<label class="label label-default label-danger">一卡通申请提现，待结算</label>{/if}
						<br>
						<br>{if $settlementRecord['settletype']==1}<label class="label label-default label-success">手动处理{elseif $settlementRecord['settletype']==2}<label class="label label-default label-info">微信零钱{else}<label class="label label-default">未结算{/if}</label>
					</td>
					<td>{php echo date('Y-m-d',$settlementRecord['applytime'])}<br>{php echo date('H:i:s',$settlementRecord['applytime'])}</td>
					<td>{php echo date('Y-m-d',$settlementRecord['updatetime'])}<br>{php echo date('H:i:s',$settlementRecord['updatetime'])}</td>
					<td>{if $settlementRecord['status']==1}<label class="label label-default label-info">代理审核中</label>{/if}
						{if $settlementRecord['status']==2}<label class="label label-default label-danger">系统审核中</label>{/if}
						{if $settlementRecord['status']==3}<label class="label label-default label-success">系统审核通过，待结算</label>{/if}
						{if $settlementRecord['status']==4}<label class="label label-default label-success">已结算到代理</label>{/if}
						{if $settlementRecord['status']==5}<label class="label label-default label-success">已结算到商家</label>{/if}
						{if $settlementRecord['status']==-1}<label class="label label-default label-default">系统审核不通过</label>{/if}
						{if $settlementRecord['status']==-2}<label class="label label-default label-default">代理审核不通过</label>{/if}
					</td>
						<td>
							{$settlementRecord['ordernum']}
						</td>
				</tr>
				<tr>
			</tr>
			</tbody>
		</table>
	</div>
    <div class="panel-body">
    <div class="panel-body">
         <div class="form-group">
            <label class="col-sm-2 control-label">申请代理</label>
            <div class="col-sm-9">
                <div class="form-control-static">{$settlementRecord['aName']}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">申请商家</label>
            <div class="col-sm-9">
                <div class="form-control-static">{$settlementRecord['sName']}</div>
            </div>
        </div>
        <div class="form-group">
			<label class="col-sm-2 control-label" >总提成</label>
			<div class="col-md-4">
			<div class="input-group">
				<input type="text" name="spercent" class="form-control" value="{$settlementRecord['spercent']}" />
				<span class="input-group-addon">%</span>
			</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" >佣金</label>
			<div class="col-md-4">
			<div class="input-group">
				<span class="input-group-addon">￥</span>
				<input type="text" name="spercentMoney" class="form-control" value="{php echo sprintf("%.2f", $settlementRecord['spercent']*$settlementRecord['sapplymoney']/100)}" />
			</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" >实际结算给商家</label>
			<div class="col-md-4">
			<div class="input-group">
				<span class="input-group-addon">￥</span>
				<input type="text" name="money" class="form-control" value="{php echo sprintf("%.2f",$settlementRecord['sapplymoney'] -  $settlementRecord['spercent']*$settlementRecord['sapplymoney']/100)}" />
			</div>
			</div>
		</div>
        <div class="form-group">
            <label class="col-sm-2 control-label"></label>
            <div class="col-sm-9">
                    <input type="hidden" name="id" value="{$id}">
                    <input type="hidden" name="accountType" value="{$_GPC['accountType']}">
                    <input type="hidden" name="token" value="{$_W['token']}">
                    <input name="submit" type="submit" value="确定" class="btn btn-primary span2" onclick="return confirm('确认？');return false;">
            </div>
           </div>
  
        </div>
        </div>
    </div>
 
</form>
{/if}
</div>
{elseif $_GPC['type']=='settlementRecord'}
<div class="main">
   <!--<div class="panel panel-default">
		<div class="table-responsive">
			<table class="table table-hover" style="min-width: 300px;">
				<tbody>
					<tr>
						<td><image src="{php echo tomedia($merchant['thumb']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
						<td>{$merchant['name']}</td>
						<td>总成交额：{if $merchant['amount']}{$merchant['amount']}元{else}0.00元{/if}</td>
						<td>目前可结算金额：{if $merchant['no_money']}{$merchant['no_money']}元{else}0.00元{/if}</td>
						<td>需上缴佣金：{php echo currency_format($merchant['no_money']*$merchant['percent']*0.01);}元</td>
						<td>佣金百分比：{if !empty($merchant['percent'])}{$merchant['percent']}%{else}0.00%{/if}</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>-->

	<div class="panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
						<th style="width:80px;">处理状态</th>
						<th style="width:80px;">结算金额</th>
						<th style="width:80px;">到账金额</th>
						<th style="width:80px;">佣金</th>
						<th style="width:80px;">佣金百分比</th>
						<th style="width:80px;">操作时间</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $item}
					<tr>
						<td>
							{if $item['status']==1}<label class="label label-default label-default">待确认</label>{/if}
							{if $item['status']==2}<label class="label label-default label-danger">已确认，待打款</label>{/if}
							{if $item['status']==3}<label class="label label-default label-success">已打款</label>{/if}
						</td>
						<td>{$item['money']}元</td>
						<td>{$item['get_money']}元</td>
						<td>{if $item['commission']}{$item['commission']}{else}0.00{/if}</td>
						<td>{if $item['percent']}{$item['percent']}{else}0.00{/if}%</td>
						<td>{php echo date("Y-m-d H:i:s",$item['createtime'])}</td>
					</tr>
					{/loop}
				</tbody>
			</table>
		</div>
	</div>
	{$pager}
	{if empty($list)}
	    <div class="panel-body" style="text-align: center;padding:30px;">
	        暂时没有任何数据!
	    </div>
	{/if}
</div>

{elseif $_GPC['type'] == 'moneyRecord'}
<div class="main">
    <!--<div class="panel panel-default">
		<div class="table-responsive">
			<table class="table table-hover" style="min-width: 300px;">
				<tbody>
					<tr>
						<td><image src="{php echo tomedia($merchant['logo']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
						<td>{$merchant['storename']}</td>
						<td>总成交额：{if $merchant['amount']}{$merchant['amount']}元{else}0.00元{/if}</td>
						<td>目前可结算金额：{if $merchant['no_money']}{$merchant['no_money']}元{else}0.00元{/if}</td>
						<td>佣金百分比：{if !empty($merchant['percent'])}{$merchant['percent']}%{else}0.00%{/if}</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>-->

	<div class="panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				{loop $moneyRecord $item1}
					<tr>
						<td>{if !empty($item1['order'])}
							订单支付 &nbsp;ID：<a href="#">{$item1['orderid']}</a><br>
							{$item1['order']['name']}
							{else}商家结算{/if}
						</td>
						<td>{if $item1['type']==1}支付成功，总金额
							{elseif $item1['type']==2 || $item['type']==9}发货(核销)成功，可结算金额
							{elseif $item1['type']==3}取消发货(核销)，可结算金额
							{elseif $item1['type']==4}商家结算，可结算金额
							{elseif $item1['type']==5}退款，总金额
							{/if}&nbsp;&nbsp;  <span style="color: #F26C4F;font-size: 20px;"><b>{if $item1['money']>0}+{/if}</b>{$item1['money']}</span>
							
						</td>
						<td>{$item1['detail']}</td>
						<td>{php echo date("Y-m-d H:i:s",$item1['createtime']);}</td>
					</tr>
					{/loop}
			</table>
		</div>
	</div>
	{$pager}
</div>
{/if}
{php include wl_template('common/footer');}
